# -*- encoding: utf-8 -*-
"""
@Author  :   BillFun
@License :   (C) Copyright 2013-2017, JieInfo
@Software:   PyCharm
@File    :   main2.py
@Time    :   2018/3/27 23:30
@Desc    :
"""
# from calExcel import excel_obj
from calUtil import until
from openpyxl import load_workbook
import os

# 需要计算的月份
g_cal_month = 0
# 需要计算表类型
g_table_type = ''
# 计算方式 new
g_cal_type = ''
# 配置文件名
g_para_file = ''
# excel存放路径
g_excel_dir_name = ''
# 获取执行程序所在的路径
g_exe_path = ''


def read_para(path, file_name):
    # 获取员工信息
    wb_para = load_workbook(path + file_name, read_only=True)
    sheet_staff = wb_para.get_sheet_by_name('staff')
    for row in sheet_staff.rows:
        for cell in row:
            print(cell.value)
    # 获取部门信息

    pass


def chk_para():
    # 校验员工ID是否重复
    # 校验员工部门是否存在

    # 校验员工信息是否完整
    pass


def init():
    global g_cal_month
    g_cal_month = input('请输入需要计算的月份，如201802\n')

    if g_cal_month.strip() == '':
        print('输入为空，默认使用上个月作为运算周期')
        g_cal_month = until.get_last_month

    if until.is_month(g_cal_month) is not True:
        print('请输入正确的月份格式YYYYMM，如201802')
        exit(-1)

    # 固定工资
    global g_table_type
    g_table_type = 'regular_pay'
    # 全新计算
    global g_cal_type
    g_cal_type = 'new'
    global g_para_file
    g_para_file = 'base.xlsx'
    global g_excel_dir_name
    g_excel_dir_name = 'excelFile'
    global g_exe_path
    g_exe_path = os.getcwd() + "\\" + g_excel_dir_name


if __name__ == '__main__':
    init()
    print('程序基础信息初始化完成!')
    read_para(g_exe_path, g_para_file)
    print('获取员工和部门信息完成!')
